package com.greensam.pixelengine.pojo.vo.spaceuser.response;

import cn.hutool.core.bean.BeanUtil;
import com.greensam.pixelengine.pojo.base.BaseDto;
import com.greensam.pixelengine.pojo.entity.SpaceUserPo;
import com.greensam.pixelengine.pojo.vo.space.response.SpaceVo;
import com.greensam.pixelengine.pojo.vo.user.response.UserVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import java.io.Serial;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * @author Ma Chengrui
 * @since 2025/9/22 15:50
 */
@Getter
@Setter
@Schema(title = "空间成员信息")
public class SpaceUserVo extends BaseDto {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(title = "空间成员ID")
    private Long id;

    @Schema(title = "空间ID")
    private Long spaceId;

    @Schema(title = "用户ID")
    private Long userId;

    @Schema(title = "角色ID")
    private Long roleId;

    @Schema(title = "创建者id")
    private Long createBy;

    @Schema(title = "创建时间")
    private LocalDateTime createTime;

    @Schema(title = "更新者id")
    private Long updateBy;

    @Schema(title = "更新时间")
    private LocalDateTime updateTime;

    @Schema(title = "用户信息")
    private UserVo user;

    @Schema(title = "空间信息")
    private SpaceVo space;

    /**
     * 空间实体类转封装类
     *
     * @param po 空间实体类
     * @author Ma Chengrui
     * @since 2025/9/22
     */
    public static SpaceUserVo spaceUserPo2Vo(SpaceUserPo po) {
        if (Objects.isNull(po)) {
            return null;
        }
        return BeanUtil.copyProperties(po, SpaceUserVo.class);
    }
}
